package day04;

import java.util.Scanner;
import java.util.Stack;

/**
 * @author tongchen
 * @create 2022-11-23 19:32
 */
public class Day04_02 {
    public static void main(String[] args) {
        //定义输入
        Scanner scan =new Scanner(System.in);
        int num=scan.nextInt();
        int n=scan.nextInt();
      //考虑到Stack相对于StringBuilder不能存储相对于数字的正负符号,决定采用StringBuilder方法进行字符串的拼接
        StringBuilder sb = new StringBuilder();
        //定义字符串进行取数
        String standard="0123456789ABCDEF";
        //定义标志位进行判断正负
        boolean flag=false;;
        if(num<0){
            flag=true;
        }
        while(num!=0){
            sb.append(standard.charAt(num%n));
            num/=n;
        }
        //判断正负
        if(flag==true){
            sb.append('-');
        }
        //进行反转即可
        System.out.println(sb.reverse());
    }

}
